trigger UpdateUserManagerOnObjects on User (before update,after Update) {

Set<Id> usrset = New Set<Id>();
Map<id,id> UserManagerMap = new Map<id,id>();
IF(Trigger.ISBEFORE){
    for(User  usrec:Trigger.new){
        If(usrec.ManagerId!=Trigger.OldMap.get(usrec.Id).ManagerId && usrec.SFA_Office__c != NULL && usrec.SFA_Office__c==Trigger.OldMap.get(usrec.Id).SFA_Office__c){
            usrec.OOR_Office_Code_Old__c = usrec.SFA_Office__c;
            usrec.User_Manager_OLD__c=usrec.ManagerId;
            usrec.OORLeadManagerUpdate__c=True;

            
        }
        else If(usrec.ManagerId!=Trigger.OldMap.get(usrec.Id).ManagerId && usrec.SFA_Office__c != NULL && usrec.SFA_Office__c!=Trigger.OldMap.get(usrec.Id).SFA_Office__c){
            usrec.User_Manager_OLD__c=Trigger.OldMap.get(usrec.Id).ManagerId;
            usrec.OORLeadManagerUpdate__c=False;
        }   
    }
}
IF(Trigger.ISAFTER){
    for(User  usrec:Trigger.new){    
       
           If(usrec.ManagerId!=Trigger.OldMap.get(usrec.Id).ManagerId && usrec.SFA_Office__c != NULL && usrec.SFA_Office__c==Trigger.OldMap.get(usrec.Id).SFA_Office__c){
               //usrList.add(usrec);
               UserManagerMap.put(usrec.Id,usrec.ManagerId);
               usrset.add(usrec.Id);
               //usrec.OORLeadManagerUpdate__c=True;

           }
      
    }
   /* 
   if(usrset.size()>0)
    { 
      ID localAdvertiserRecordTypeID = RecordTypeHelper.GetRecordTypeID('Lead', 'Local Advertiser');
      OORUpdateLeads job= New OORUpdateLeads();
      job.UserManagerMaplist = UserManagerMap;
      job.userIdset = usrset;
      job.Query = 'Select Id,OwnerId,User_Manager__c from Lead where RecordTypeId =\''+localAdvertiserRecordTypeID+ '\' AND  OwnerId IN:userIdset AND ISCONVERTED = FALSE';
      Database.executeBatch(job, 100);    
     } 
    */
    }
}